﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class LocationCache : Singleton<LocationCache>
{
    private Dictionary<string, Location> locDic = new Dictionary<string, Location>();

    public void AddLoc(string id,Location loc)
    {
        locDic.Add(id, loc);
    }
    public void DelLoc(string id)
    {
        locDic.Remove(id);
    }
    public void SetLoc(string id, float N,float E)
    {
        if(locDic.ContainsKey(id))
        {
            locDic[id].latitude = N;
            locDic[id].longitude = E;
        }
        else
        {
            AddLoc(id,new Location(N,E));
        }
    }

    public Location GetLoc(string id)
    {
        Location loc;
        if(locDic.TryGetValue(id,out loc))
        {
            return loc;
        }
        return null;
    }
}
